﻿package controllers.myinfo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import models.Cjdata;
import models.Estate2;
import models.Estate2gd;
import models.Estate2other;

import com.et.mvc.BinaryView;
import com.et.mvc.JsonView;
import com.et.mvc.MultipartFile;
import com.et.mvc.TextView;
import com.et.mvc.View;

import com.et.mvc.filter.BeforeFilter;
import com.et.mvc.filter.BeforeFilters;

import controllers.ApplicationController;


public class CalcController extends ApplicationController {
	
	public void price2(int estype) throws Exception{
    	long l1 = 0;
    	long l2 = 0;
    	long l3 = 0;
    	long l4 = 0;
    	long l5 = 0;
    	long l6 = 0;
    	long l7 = 0;
    	long l8 = 0;
    	String modestr = "出售";
    	
    	switch (estype) {
		case 1:
			l1 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >0 and totalprice <=100000)" , null);
			l2 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >100000 and totalprice <=300000)" , null);
			l3 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >300000 and totalprice <=500000)" , null);
			l4 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >500000 and totalprice <=1000000)" , null);
			l5 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >1000000 and totalprice <=1500000)" , null);
			l6 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >1500000 and totalprice <=2000000)" , null);
			l7 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >2000000 )" , null);
			l8 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and (totalprice is null)" , null);
			break;
		case 2:
			l1 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >0 and totalprice <=100000)" , null);
			l2 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >100000 and totalprice <=300000)" , null);
			l3 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >300000 and totalprice <=500000)" , null);
			l4 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >500000 and totalprice <=1000000)" , null);
			l5 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >1000000 and totalprice <=1500000)" , null);
			l6 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >1500000 and totalprice <=2000000)" , null);
			l7 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >2000000 )" , null);
			l8 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and (totalprice is null)" , null);
			break;
		default:
			l1 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >0 and totalprice <=100000)" , null);
			l2 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >100000 and totalprice <=300000)" , null);
			l3 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >300000 and totalprice <=500000)" , null);
			l4 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >500000 and totalprice <=1000000)" , null);
			l5 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >1000000 and totalprice <=1500000)" , null);
			l6 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >1500000 and totalprice <=2000000)" , null);
			l7 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and (totalprice >2000000 )" , null);
			l8 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and (totalprice is null)" , null);
			break;
		}
    	
    	request.setAttribute("estype", estype);
    	request.setAttribute("l1", l1);
    	request.setAttribute("l2", l2);
    	request.setAttribute("l3", l3);
    	request.setAttribute("l4", l4);
    	request.setAttribute("l5", l5);
    	request.setAttribute("l6", l6);
    	request.setAttribute("l7", l7);
    	request.setAttribute("l8", l8);
	}
	
	public void price1(int estype) throws Exception{
    	long l1 = 0;
    	long l2 = 0;
    	long l3 = 0;
    	long l4 = 0;
    	long l5 = 0;
    	long l6 = 0;
    	long l7 = 0;
    	long l8 = 0;
    	String modestr = "出租";
    	
    	switch (estype) {
		case 1:
			l1 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and (price >0 and price <=1000)" , null);
			l2 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and (price >1000 and price <=1500)" , null);
			l3 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and (price >1500 and price <=2000)" , null);
			l4 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and (price >2000 and price <=2500)" , null);
			l5 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and (price >2500 and price <=3000)" , null);
			l6 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and (price >3000 and price <=4000)" , null);
			l7 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and (price >4000 and price <=5000)" , null);
			l8 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and (price >5000 )" , null);
			break;
		case 2:
			l1 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and (price >0 and price <=1000)" , null);
			l2 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and (price >1000 and price <=1500)" , null);
			l3 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and (price >1500 and price <=2000)" , null);
			l4 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and (price >2000 and price <=2500)" , null);
			l5 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and (price >2500 and price <=3000)" , null);
			l6 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and (price >3000 and price <=4000)" , null);
			l7 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and (price >4000 and price <=5000)" , null);
			l8 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and (price >5000 )" , null);
			break;
		default:
			l1 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and (price >0 and price <=1000)" , null);
			l2 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and (price >1000 and price <=1500)" , null);
			l3 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and (price >1500 and price <=2000)" , null);
			l4 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and (price >2000 and price <=2500)" , null);
			l5 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and (price >2500 and price <=3000)" , null);
			l6 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and (price >3000 and price <=4000)" , null);
			l7 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and (price >4000 and price <=5000)" , null);
			l8 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and (price >5000 )" , null);
			break;
		}
    	
    	request.setAttribute("estype", estype);
    	request.setAttribute("l1", l1);
    	request.setAttribute("l2", l2);
    	request.setAttribute("l3", l3);
    	request.setAttribute("l4", l4);
    	request.setAttribute("l5", l5);
    	request.setAttribute("l6", l6);
    	request.setAttribute("l7", l7);
    	request.setAttribute("l8", l8);
	}
	
	public void calc1(int mode,int estype) throws Exception{
    	long l1 = 0;
    	long l2 = 0;
    	long l3 = 0;
    	long l4 = 0;
    	long l5 = 0;
    	long l6 = 0;
    	long l7 = 0;
    	String modestr = "出租";
    	if (mode == 2) modestr = "出售";
    	switch (estype) {
		case 1:
			l1 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and room like '1房%'" , null);
			l2 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and room like '2房%'" , null);
			l3 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and room like '3房%'" , null);
			l4 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and room like '4房%'" , null);
			l5 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and room like '5房%'" , null);
			l6 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and room like '6房%'" , null);
			l7 = Estate2gd.count(Estate2gd.class,"mode = '"+modestr+"' and flag ='0' and room not like '1房%' and room not like '2房%' and room not like '3房%' and room not like '4房%' and room not like '5房%' and room not like '6房%'" , null);
			break;
		case 2:
			l1 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and room like '1房%'" , null);
			l2 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and room like '2房%'" , null);
			l3 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and room like '3房%'" , null);
			l4 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and room like '4房%'" , null);
			l5 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and room like '5房%'" , null);
			l6 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and room like '6房%'" , null);
			l7 = Estate2other.count(Estate2other.class,"mode = '"+modestr+"' and flag ='0' and room not like '1房%' and room not like '2房%' and room not like '3房%' and room not like '4房%' and room not like '5房%' and room not like '6房%'" , null);
			break;
		default:
			l1 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and room like '1房%'" , null);
			l2 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and room like '2房%'" , null);
			l3 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and room like '3房%'" , null);
			l4 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and room like '4房%'" , null);
			l5 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and room like '5房%'" , null);
			l6 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and room like '6房%'" , null);
			l7 = Estate2.count(Estate2.class,"mode = '"+modestr+"' and flag ='0' and room not like '1房%' and room not like '2房%' and room not like '3房%' and room not like '4房%' and room not like '5房%' and room not like '6房%'" , null);
			
			break;
		}
    	
    	request.setAttribute("estype", estype);
    	request.setAttribute("l1", l1);
    	request.setAttribute("l2", l2);
    	request.setAttribute("l3", l3);
    	request.setAttribute("l4", l4);
    	request.setAttribute("l5", l5);
    	request.setAttribute("l6", l6);
    	request.setAttribute("l7", l7);
    	
	}
	
	public void index(int estype) throws Exception{
    	long l1 = 0;
    	long l2 = 0;
    	switch (estype) {
		case 1:
			l1 = Estate2gd.count(Estate2gd.class,"mode = '出租' and flag ='0'" , null);
			l2 = Estate2gd.count(Estate2gd.class,"mode = '出售' and flag ='0'" , null);
			break;
		case 2:
			l1 = Estate2other.count(Estate2other.class,"mode = '出租' and flag ='0'" , null);
			l2 = Estate2other.count(Estate2other.class,"mode = '出售' and flag ='0'" , null);
			break;
		default:
			l1 = Estate2.count(Estate2.class,"mode = '出租' and flag ='0'" , null);
			l2 = Estate2.count(Estate2.class,"mode = '出售' and flag ='0'" , null);
			break;
		}
    	
    	request.setAttribute("estype", estype);
    	request.setAttribute("l1", l1);
    	request.setAttribute("l2", l2);
	}
	
	
	
}
